package com.example.content.fragment.main

import androidx.fragment.app.Fragment
import com.example.content.*
import com.example.content.adapter.viewpager.HomePagerAdapter
import com.example.content.databinding.FragmentHomeBinding
import com.example.content.fragment.BaseMvvmFragment
import com.example.content.fragment.CommonListFragment
import com.example.content.manager.RouterMgr
import com.example.content.viewmodule.main.CommonHomeViewModel
import com.gyf.immersionbar.ImmersionBar

class HomeFragment : BaseMvvmFragment<FragmentHomeBinding, CommonHomeViewModel>() {

    private val fragments = mutableListOf<Fragment>()

    private val titles = arrayOf("热门推荐","看美女","看帅哥","关注")

    override fun getLayoutId() = R.layout.fragment_home

    override fun initView() {
        fragments.add(CommonListFragment.newInstance(REMD_ALL,false))
        fragments.add(CommonListFragment.newInstance(REMD_FEMAIL, false))
        fragments.add(CommonListFragment.newInstance(REMD_MAN, false))
        fragments.add(CommonListFragment.newInstance(REMD_COLLECT, false))
        dataBinding.viewPager.adapter = HomePagerAdapter(childFragmentManager, fragments, titles)
//        dataBinding.tabLayout.setupWithViewPager(dataBinding.viewPager)
        dataBinding.slidingTab.setViewPager(dataBinding.viewPager, titles)
    }

    override fun initListener() {
        dataBinding.search.setOnClickListener {
            RouterMgr.searchActivity()
        }
    }


    companion object {
        @JvmStatic
        fun newInstance() = HomeFragment()
    }

    override fun getViewModuleClass(): Class<CommonHomeViewModel> {
        return CommonHomeViewModel::class.java
    }
}